<template>
  <div
    class="action-header"
    :style="{
      width: `calc(100% - ${2 * margin}px)`,
      margin: `0 ${margin}px`
    }">
    <div class="title">
      <div v-if="$slots.img" class="img">
        <slot name="img" />
      </div>
      <div v-else class="img">
        <img src="./img/icon.png" alt="" />
      </div>
      <div class="text">{{title}}</div>
    </div>
    <div class="slot">
      <slot />
    </div>
    <div class="block"></div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ''
    },
    margin: {
      type: String,
      default: '40'
    }
  }
}
</script>

<style lang="scss" scoped>
  @import 'common/scss/color';

  .action-header {
    height: 50px;
    display: flex;
    align-items: center;
    position: relative;
    border-bottom: 1px solid $Color-border;
    > .title {
      display: flex;
      align-items: center;
      > .img {
        flex: 0 0 12px;
        height: 12px;
        overflow: hidden;
        margin-right: 5px;
      }
      > .text {
        color: $Color-text;
        font-size: 14px;
        font-weight: bold;
      }
    }
    > .slot {
      flex: 1;
    }
    > .block {
      width: 40px;
      height: 4px;
      background-color: #DEDEDE;
      position: absolute;
      left: 0;
      bottom: 0;
    }
  }
</style>
